<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<script src="/static/js/jquery-1.11.1.min.js"></script>
<head th:include="common/head :: htmlhead">
<body>
<div class="layui-fluid" style="padding: 10px;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">数据导入</div>
                <div class="layui-card-body" >
                    <div class="layui-form" >
                        <div class="layui-form-item">
                            <div><b>导入网点月数据：</b></div>
                            <div class="layui-inline">
                                <label class="layui-form-label">请选择月份</label>
                                <div class="layui-input-block">
                                    <input type="text" name="yuefen" placeholder=""
                                           autocomplete="off" class="layui-input" id="yuefen">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search1" id="search1">
                                    <i class="layui-icon layui-icon-add-circle layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div><b>导入网点日数据：</b></div>
                            <div class="layui-inline">
                                <label class="layui-form-label">请选择日期</label>
                                <div class="layui-input-block">
                                    <input type="text" name="date" placeholder=""
                                           autocomplete="off" class="layui-input" id="date">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search2" id="search2">
                                    <i class="layui-icon layui-icon-add-circle layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div><b>导入快递员月数据：</b></div>
                            <div class="layui-inline">
                                <label class="layui-form-label">请选择月份</label>
                                <div class="layui-input-block">
                                    <input type="text" name="yuefen" placeholder=""
                                           autocomplete="off" class="layui-input" id="yuefen1">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search3" id="search3">
                                    <i class="layui-icon layui-icon-add-circle layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div><b>导入快递员日数据：</b></div>
                            <div class="layui-inline">
                                <label class="layui-form-label">请选择日期</label>
                                <div class="layui-input-block">
                                    <input type="text" name="date" placeholder=""
                                           autocomplete="off" class="layui-input" id="date1">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search4" id="search4">
                                    <i class="layui-icon layui-icon-add-circle layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/static/layui/layui.js" charset="utf-8"></script>

<script type="text/javascript">
    layui.config({
        base: '/static/lib/' //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['form','laydate','index'],
        function() {
            var laydate = layui.laydate;
            var form = layui.form;
            var $ = layui.$;

            var today = new Date();
            nowDate = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
            nowMonth = today.getFullYear()+'-'+(today.getMonth()+1);

            //执行一个laydate实例
            var yuefen = laydate.render({
                elem: '#yuefen' //指定元素
                ,type: 'month'
                ,max: 0
                ,value: '[[${yuefen}]]'
            });


            //执行一个laydate实例
            var date = laydate.render({
                elem: '#date' //指定元素
                , range: true
                ,max: 0
                ,value: '[[${date}]]'
            });


            //执行一个laydate实例
            laydate.render({
                elem: '#yuefen1' //指定元素
                ,type: 'month'
                ,max: 0
                ,value: '[[${yuefen1}]]'
            });


            //执行一个laydate实例
            laydate.render({
                elem: '#date1' //指定元素
                , range: true
                ,max: 0
                ,value: '[[${date1}]]'
            });

            document.getElementById('yuefen').value = nowMonth;
            document.getElementById('yuefen1').value = nowMonth;
            document.getElementById('date').value = nowDate+' - '+nowDate;
            document.getElementById('date1').value = nowDate+' - '+nowDate;


            form.on('submit(LAY-app-contlist-search1)', function(data){
                $.ajax({
                    url:'/importOrgMonth?yuefen0='+document.getElementById("yuefen").value,
                    async: false,
                    type:"POST",
                    dataType: "text",
                    data:data.field,
                    success:function(data){
                        data=$.parseJSON(data);
                        console.log(data.msg);
                        if (data.msg==="success") {
                            layer.alert("导入成功",{
                                icon: 6,
                                btn: ['OK']
                            });
                        }
                        else {
                            layer.alert("导入失败",{
                                icon: 5,
                                btn: ['关闭']
                            });
                        }
                    }
                })
            })

            form.on('submit(LAY-app-contlist-search2)', function(data){
                $.ajax({
                    url:"/importOrgDaily?date0="+document.getElementById("date").value,
                    async: false,
                    type:"POST",
                    dataType: "text",
                    data:data.field,
                    success:function(data){
                        data=$.parseJSON(data);
                        console.log(data.msg);
                        if (data.msg==="success") {
                            layer.alert("导入成功",{
                                icon: 6,
                                btn: ['OK']
                            });
                        }
                        else {
                            layer.alert("导入失败",{
                                icon: 5,
                                btn: ['关闭']
                            });
                        }
                    }
                })
            })

            form.on('submit(LAY-app-contlist-search3)', function(data){
                $.ajax({
                    url:"/importDlvyMonth?yuefen1="+document.getElementById("yuefen1").value,
                    async: false,
                    type:"POST",
                    dataType: "text",
                    data:data.field,
                    success:function(data){
                        data=$.parseJSON(data);
                        console.log(data.msg);
                        if (data.msg==="success") {
                            layer.alert("导入成功",{
                                icon: 6,
                                btn: ['OK']
                            });
                        }
                        else {
                            layer.alert("导入失败",{
                                icon: 5,
                                btn: ['关闭']
                            });
                        }
                    }
                })
            })
            form.on('submit(LAY-app-contlist-search4)', function(data){
                $.ajax({
                    // url:"/importDlvyDaily?date1="+document.getElementById("date1").value,
                    url:"/importDlvyDaily",
                    async: false,
                    type:"POST",
                    dataType: "text",
                    data:data.field,
                    success:function(data){
                        data=$.parseJSON(data);
                        console.log(data.msg);
                        if (data.msg==="success") {
                            layer.alert("导入成功",{
                                icon: 6,
                                btn: ['OK']
                            });
                        }
                        else {
                            layer.alert("导入失败",{
                                icon: 5,
                                btn: ['关闭']
                            });
                        }
                    }
                })
            })

        })

</script>
</body>
</html>